# eric7.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleCheckerDialog

Module implementing a dialog to show the results of the code style check.

### Global Attributes

None

### Classes

CodeStyleCheckerDialog | Class implementing a dialog to show the results of the code style check.

### Functions

None

## CodeStyleCheckerDialog

Class implementing a dialog to show the results of the code style check.

### Derived from

QDialog, Ui_CodeStyleCheckerDialog

### Class Attributes

argsRole
availableFutures
checkCategories
codeRole
cryptoBitSelectionsDsaRsa
cryptoBitSelectionsEc
filenameRole
fixableRole
hasResults
ignoredRole
lineRole
messageRole
noFiles
noResults
positionRole

### Class Methods

None

### Methods

CodeStyleCheckerDialog | Constructor
__assembleExcludeMessages | Private method to assemble the list of excluded checks.
__assembleIncludeMessages | Private method to assemble the list of included checks.
__batchFinished | Private slot handling the completion of a batch job.
__clearErrors | Private method to clear all warning markers of open editors to be checked.
__createErrorItem | Private slot to create a new error item in the result list.
__createFileErrorItem | Private method to create an error entry for a given file.
__createResultItem | Private method to create an entry in the result list.
__defaultStatistics | Private method to return the default statistics entry.
__finish | Private slot called when the code style check finished or the user pressed the cancel button.
__getBanRelativeImportsValue | Private method to get the value corresponding the selected button.
__getBuiltinsIgnoreList | Private method to get a dictionary containing the builtins assignments to be ignored.
__getCategories | Private method to get the enabled or disabled checker categories.
__getCommentedCodeCheckerWhiteList | Private method to get the list of commented code whitelist patterns.
__getEol | Private method to get the applicable eol string.
__getSelectedFixableItems | Private method to extract all selected items for fixable issues.
__getSelectedFutureImports | Private method to get the expected future imports.
__initBuiltinsIgnoreList | Private method to populate the list of shadowed builtins to be ignored.
__initCategoriesList | Private method to set the enabled status of the checker categories.
__initCommentedCodeCheckerWhiteList | Private method to populate the list of commented code whitelist patterns.
__initFuturesList | Private method to set the selected status of the future imports.
__itemFixable | Private method to check, if an item has a fixable issue.
__migrateIssueCodes | Private method to migrate the issue codes to the form 'category'-'number'.
__modifyFixedResultItem | Private method to modify a result list entry to show its positive fixed state.
__modifyOptions | Private method to modify the options based on eflag: entries.
__prepareProgress | Private method to prepare the progress tab for the next run.
__processError | Private slot to process an error indication from the service.
__processResult | Private slot called after perfoming a style check on one file.
__resetStatistics | Private slot to reset the statistics data.
__resort | Private method to resort the tree.
__selectCodes | Private method to select message codes via a selection dialog.
__setBanRelativeImports | Private method to set the button according to the ban relative imports setting.
__updateFixerStatistics | Private method to update the collected fixer related statistics.
__updateProgress | Private method to update the progress tab.
__updateStatistics | Private method to update the collected statistics.
check | Public method to start a style check for one file.
checkBatch | Public method to start a style check batch job.
closeEvent | Protected method to handle a close event.
getDefaults | Public method to get a dictionary containing the default values.
on_addBuiltinButton_clicked | Private slot to add a built-in assignment to be ignored.
on_addWhitelistButton_clicked | Private slot to add a commented code whitelist pattern.
on_builtinsAssignmentList_itemSelectionChanged | Private slot to react upon changes of the selected builtin assignments.
on_buttonBox_clicked | Private slot called by a button of the button box clicked.
on_cancelButton_clicked | Private slot to handle the "Cancel" button press.
on_deleteBuiltinButton_clicked | Private slot to delete the selected items from the list.
on_deleteWhitelistButton_clicked | Private slot to delete the selected items from the list.
on_excludeMessagesSelectButton_clicked | Private slot to select the message codes to be excluded via a selection dialog.
on_filterButton_clicked | Private slot to filter the list of messages based on selected message code.
on_fixButton_clicked | Private slot to fix selected issues.
on_fixIssuesSelectButton_clicked | Private slot to select the issue codes to be fixed via a selection dialog.
on_includeMessagesSelectButton_clicked | Private slot to select the message codes to be included via a selection dialog.
on_loadDefaultButton_clicked | Private slot to load the default configuration values.
on_noFixIssuesSelectButton_clicked | Private slot to select the issue codes not to be fixed via a selection dialog.
on_resetDefaultButton_clicked | Private slot to reset the configuration values to their default values.
on_restartButton_clicked | Private slot to restart a code style check run.
on_resultList_itemActivated | Private slot to handle the activation of an item.
on_resultList_itemSelectionChanged | Private slot to change the dialog state depending on the selection.
on_showButton_clicked | Private slot to handle the "Show" button press.
on_startButton_clicked | Private slot to start a code style check run.
on_statisticsButton_clicked | Private slot to show the statistics dialog.
on_storeDefaultButton_clicked | Private slot to store the current configuration values as default values.
on_whitelistWidget_itemSelectionChanged | Private slot to react upon changes of the selected whitelist patterns.
prepare | Public method to prepare the dialog with a list of filenames.
start | Public slot to start the code style check.

### Static Methods

None

#### CodeStyleCheckerDialog (Constructor)

CodeStyleCheckerDialog(styleCheckService, project=None, parent=None)

Constructor

styleCheckService (CodeStyleCheckService)
  reference to the service
project (Project)
  reference to the project if called on project or project browser level
parent (QWidget)
  reference to the parent widget

#### CodeStyleCheckerDialog.__assembleExcludeMessages

__assembleExcludeMessages()

Private method to assemble the list of excluded checks.

Return:
  list of excluded checks as a comma separated string.

Return Type:
  str

#### CodeStyleCheckerDialog.__assembleIncludeMessages

__assembleIncludeMessages()

Private method to assemble the list of included checks.

Return:
  list of included checks as a comma separated string.

Return Type:
  str

#### CodeStyleCheckerDialog.__batchFinished

__batchFinished()

Private slot handling the completion of a batch job.

#### CodeStyleCheckerDialog.__clearErrors

__clearErrors(files)

Private method to clear all warning markers of open editors to be checked.

files (list of str)
  list of files to be checked

#### CodeStyleCheckerDialog.__createErrorItem

__createErrorItem(filename, message)

Private slot to create a new error item in the result list.

filename (str)
  name of the file
message (str)
  error message

#### CodeStyleCheckerDialog.__createFileErrorItem

__createFileErrorItem(filename, message)

Private method to create an error entry for a given file.

filename (str)
  file name of the file
message (str)
  error message text

#### CodeStyleCheckerDialog.__createResultItem

__createResultItem(filename, result)

Private method to create an entry in the result list.

filename (str)
  file name of the file
result (dict)
  dictionary containing check result data

Return:
  reference to the created item

Return Type:
  QTreeWidgetItem

#### CodeStyleCheckerDialog.__defaultStatistics

__defaultStatistics()

Private method to return the default statistics entry.

Return:
  dictionary with default statistics entry

Return Type:
  dict

#### CodeStyleCheckerDialog.__finish

__finish()

Private slot called when the code style check finished or the user pressed the cancel button.

#### CodeStyleCheckerDialog.__getBanRelativeImportsValue

__getBanRelativeImportsValue()

Private method to get the value corresponding the selected button.

Return:
  value for the BanRelativeImports argument

Return Type:
  str

#### CodeStyleCheckerDialog.__getBuiltinsIgnoreList

__getBuiltinsIgnoreList()

Private method to get a dictionary containing the builtins assignments to be ignored.

Return:
  dictionary containing the builtins assignments to be ignored

Return Type:
  dict of list of str

#### CodeStyleCheckerDialog.__getCategories

__getCategories(enabled, asList=False)

Private method to get the enabled or disabled checker categories.

enabled (bool)
  flag indicating to return enabled categories
asList (bool)
  flag indicating to return the checker categories as a Python list

Return:
  checker categories as a list or comma separated string

Return Type:
  str or list of str

#### CodeStyleCheckerDialog.__getCommentedCodeCheckerWhiteList

__getCommentedCodeCheckerWhiteList()

Private method to get the list of commented code whitelist patterns.

Return:
  list of commented code whitelist patterns

Return Type:
  list of str

#### CodeStyleCheckerDialog.__getEol

__getEol(fn)

Private method to get the applicable eol string.

fn (str)
  filename where to determine the line ending

Return:
  eol string

Return Type:
  str

#### CodeStyleCheckerDialog.__getSelectedFixableItems

__getSelectedFixableItems()

Private method to extract all selected items for fixable issues.

Return:
  selected items for fixable issues

Return Type:
  list of QTreeWidgetItem

#### CodeStyleCheckerDialog.__getSelectedFutureImports

__getSelectedFutureImports()

Private method to get the expected future imports.

Return:
  expected future imports as a comma separated string

Return Type:
  str

#### CodeStyleCheckerDialog.__initBuiltinsIgnoreList

__initBuiltinsIgnoreList(builtinsIgnoreDict)

Private method to populate the list of shadowed builtins to be ignored.

builtinsIgnoreDict (dict of list of str)
  dictionary containing the builtins assignments to be ignored

#### CodeStyleCheckerDialog.__initCategoriesList

__initCategoriesList(enabledCategories)

Private method to set the enabled status of the checker categories.

enabledCategories (str)
  comma separated list of enabled checker categories

#### CodeStyleCheckerDialog.__initCommentedCodeCheckerWhiteList

__initCommentedCodeCheckerWhiteList(whitelist)

Private method to populate the list of commented code whitelist patterns.

whitelist (list of str)
  list of commented code whitelist patterns

#### CodeStyleCheckerDialog.__initFuturesList

__initFuturesList(selectedFutures)

Private method to set the selected status of the future imports.

selectedFutures (str)
  comma separated list of expected future imports

#### CodeStyleCheckerDialog.__itemFixable

__itemFixable(itm)

Private method to check, if an item has a fixable issue.

itm (QTreeWidgetItem)
  item to be checked

Return:
  flag indicating a fixable issue

Return Type:
  bool

#### CodeStyleCheckerDialog.__migrateIssueCodes

__migrateIssueCodes()

Private method to migrate the issue codes to the form 'category'-'number'.

#### CodeStyleCheckerDialog.__modifyFixedResultItem

__modifyFixedResultItem(itm, result)

Private method to modify a result list entry to show its positive fixed state.

itm (QTreeWidgetItem)
  reference to the item to modify
result (dict)
  dictionary containing check result data

#### CodeStyleCheckerDialog.__modifyOptions

__modifyOptions(source)

Private method to modify the options based on eflag: entries.

This method looks for comment lines like '# eflag: noqa = M-601' at the end of the source in order to extend the list of excluded messages for one file only.

source (list of str or str)
  source text

Return:
  list of checker options

Return Type:
  list

#### CodeStyleCheckerDialog.__prepareProgress

__prepareProgress()

Private method to prepare the progress tab for the next run.

#### CodeStyleCheckerDialog.__processError

__processError(fn, msg)

Private slot to process an error indication from the service.

fn (str)
  filename of the file
msg (str)
  error message

#### CodeStyleCheckerDialog.__processResult

__processResult(fn, codeStyleCheckerStats, fixes, results)

Private slot called after perfoming a style check on one file.

fn (str)
  filename of the just checked file
codeStyleCheckerStats (dict)
  stats of style and name check
fixes (int)
  number of applied fixes
results (dict)
  dictionary containing check result data

#### CodeStyleCheckerDialog.__resetStatistics

__resetStatistics()

Private slot to reset the statistics data.

#### CodeStyleCheckerDialog.__resort

__resort()

Private method to resort the tree.

#### CodeStyleCheckerDialog.__selectCodes

__selectCodes(edit, categories, showFixCodes)

Private method to select message codes via a selection dialog.

edit (QLineEdit)
  reference of the line edit to be populated
categories (list of str)
  list of message categories to omit
showFixCodes (bool)
  flag indicating to show a list of fixable issues

#### CodeStyleCheckerDialog.__setBanRelativeImports

__setBanRelativeImports(value)

Private method to set the button according to the ban relative imports setting.

value (str)
  value of the ban relative imports setting

#### CodeStyleCheckerDialog.__updateFixerStatistics

__updateFixerStatistics(fixer)

Private method to update the collected fixer related statistics.

fixer (CodeStyleFixer)
  reference to the code style fixer

#### CodeStyleCheckerDialog.__updateProgress

__updateProgress(fn)

Private method to update the progress tab.

fn (str)
  filename of the just checked file

#### CodeStyleCheckerDialog.__updateStatistics

__updateStatistics(statistics, fixer, ignoredErrors, securityOk)

Private method to update the collected statistics.

statistics (dict)
  dictionary of statistical data with message code as key and message count as value
fixer (CodeStyleFixer)
  reference to the code style fixer
ignoredErrors (int)
  number of ignored errors
securityOk (int)
  number of acknowledged security reports

#### CodeStyleCheckerDialog.check

check(codestring="")

Public method to start a style check for one file.

The results are reported to the __processResult slot.

codestring (str)
  optional sourcestring

#### CodeStyleCheckerDialog.checkBatch

checkBatch()

Public method to start a style check batch job.

The results are reported to the __processResult slot.

#### CodeStyleCheckerDialog.closeEvent

closeEvent(_evt)

Protected method to handle a close event.

_evt (QCloseEvent)
  reference to the close event (unused)

#### CodeStyleCheckerDialog.getDefaults

getDefaults()

Public method to get a dictionary containing the default values.

Return:
  dictionary containing the default values

Return Type:
  dict

#### CodeStyleCheckerDialog.on_addBuiltinButton_clicked

on_addBuiltinButton_clicked()

Private slot to add a built-in assignment to be ignored.

#### CodeStyleCheckerDialog.on_addWhitelistButton_clicked

on_addWhitelistButton_clicked()

Private slot to add a commented code whitelist pattern.

#### CodeStyleCheckerDialog.on_builtinsAssignmentList_itemSelectionChanged

on_builtinsAssignmentList_itemSelectionChanged()

Private slot to react upon changes of the selected builtin assignments.

#### CodeStyleCheckerDialog.on_buttonBox_clicked

on_buttonBox_clicked(button)

Private slot called by a button of the button box clicked.

button (QAbstractButton)
  button that was clicked

#### CodeStyleCheckerDialog.on_cancelButton_clicked

on_cancelButton_clicked()

Private slot to handle the "Cancel" button press.

#### CodeStyleCheckerDialog.on_deleteBuiltinButton_clicked

on_deleteBuiltinButton_clicked()

Private slot to delete the selected items from the list.

#### CodeStyleCheckerDialog.on_deleteWhitelistButton_clicked

on_deleteWhitelistButton_clicked()

Private slot to delete the selected items from the list.

#### CodeStyleCheckerDialog.on_excludeMessagesSelectButton_clicked

on_excludeMessagesSelectButton_clicked()

Private slot to select the message codes to be excluded via a selection dialog.

#### CodeStyleCheckerDialog.on_filterButton_clicked

on_filterButton_clicked()

Private slot to filter the list of messages based on selected message code.

#### CodeStyleCheckerDialog.on_fixButton_clicked

on_fixButton_clicked()

Private slot to fix selected issues.

Build a dictionary of issues to fix. Update the initialized __options. Then call check with the dict as keyparam to fix selected issues.

#### CodeStyleCheckerDialog.on_fixIssuesSelectButton_clicked

on_fixIssuesSelectButton_clicked()

Private slot to select the issue codes to be fixed via a selection dialog.

#### CodeStyleCheckerDialog.on_includeMessagesSelectButton_clicked

on_includeMessagesSelectButton_clicked()

Private slot to select the message codes to be included via a selection dialog.

#### CodeStyleCheckerDialog.on_loadDefaultButton_clicked

on_loadDefaultButton_clicked()

Private slot to load the default configuration values.

#### CodeStyleCheckerDialog.on_noFixIssuesSelectButton_clicked

on_noFixIssuesSelectButton_clicked()

Private slot to select the issue codes not to be fixed via a selection dialog.

#### CodeStyleCheckerDialog.on_resetDefaultButton_clicked

on_resetDefaultButton_clicked()

Private slot to reset the configuration values to their default values.

#### CodeStyleCheckerDialog.on_restartButton_clicked

on_restartButton_clicked()

Private slot to restart a code style check run.

#### CodeStyleCheckerDialog.on_resultList_itemActivated

on_resultList_itemActivated(item, _column)

Private slot to handle the activation of an item.

item (QTreeWidgetItem)
  reference to the activated item
_column (int)
  column the item was activated in (unused)

#### CodeStyleCheckerDialog.on_resultList_itemSelectionChanged

on_resultList_itemSelectionChanged()

Private slot to change the dialog state depending on the selection.

#### CodeStyleCheckerDialog.on_showButton_clicked

on_showButton_clicked()

Private slot to handle the "Show" button press.

#### CodeStyleCheckerDialog.on_startButton_clicked

on_startButton_clicked()

Private slot to start a code style check run.

#### CodeStyleCheckerDialog.on_statisticsButton_clicked

on_statisticsButton_clicked()

Private slot to show the statistics dialog.

#### CodeStyleCheckerDialog.on_storeDefaultButton_clicked

on_storeDefaultButton_clicked()

Private slot to store the current configuration values as default values.

#### CodeStyleCheckerDialog.on_whitelistWidget_itemSelectionChanged

on_whitelistWidget_itemSelectionChanged()

Private slot to react upon changes of the selected whitelist patterns.

#### CodeStyleCheckerDialog.prepare

prepare(fileList, project)

Public method to prepare the dialog with a list of filenames.

fileList (list of str)
  list of filenames
project (Project)
  reference to the project object

#### CodeStyleCheckerDialog.start

start(fn, save=False, repeat=None)

Public slot to start the code style check.

fn (str or list of str)
  file or list of files or directory to be checked
save (bool)
  flag indicating to save the given file/file list/directory
repeat (None or bool)
  state of the repeat check box if it is not None

Up